home *** CD-ROM | disk | FTP | other *** search
/ CYBER.XPO.95 / CYBER.XPO.95 (Arsenal Computer).ISO / popreq / amiga1 / compii.lha / compii5.rexx next >
OS/2 REXX Batch file  |  1994-01-02  |  3KB  |  73 lines

  1. /*****************************************************************************
  2.    CompII5.rexx. Compares 2 files line by line....  Ignus Fast   31 Dec 1993
  3.  
  4.      This program will go through 2 files and show you the line # and left
  5. 33 chars of each line that is DIFFERENT between 2 files- I use this as an
  6. aid in updating BBSTEXT files, but it could be used for about anything.
  7.  
  8.      The reason it has to be added through CNet is because (that I know
  9. of) the normal AREXX interpreter has no way of grabbing a single
  10. keypress (and some other niceties in the CNet AREXX port!)...  Hopefully
  11. I'll  figure  out  a way someday to do it from RX.  (or get off my ass and
  12. learn C!)
  13.  
  14. *****************************************************************************/
  15. options results
  16. tx=transmit;sx=sendstring
  17. oops="###PANIC"
  18.  
  19.      tx "cbWelcome to CompII5.rexxc3, by Ignus Fastn1"
  20.      tx "This program will scan two files, and display the line # and left 33 characters of any lines that are different between the two files.  Main use is to ease updating BBSTEXT files..."
  21.  
  22. LOOP:
  23.      tx "n1cbPlease enter the names of the two files you wish to comparec1 (with paths, seperated by a comma: ex. c9cnet:bbstext,cnet:bbstext3.02c1),cb or [return] to exit:n1c3"
  24.      prompt 70 NORMAL '"-> "'
  25.      name=result
  26.      if name=oops | name="" then exit
  27.      c=index(name,",")
  28.      if length(name)<3 | c=0 then signal LOOP
  29.      ltname=left(name,c-1)
  30.      rtname=substr(name,c+1)
  31.      if ~exists(ltname) | ~exists(rtname) then do
  32.           tx "n2c9One or both of those files do not exist!  Please try again..."
  33.           signal LOOP
  34.           end
  35.  
  36.      sx "n1cbPause after every line? c1 (Default: every 20 lines) c9 [No] "
  37.      getchar
  38.      z=result
  39.      if z=oops then exit
  40.      if z~="Y" then z="N"
  41.      tx z"n2"
  42.  
  43.      call open(lt,ltname,'R')
  44.      call open(rt,rtname,'R')
  45.      tx "n2c9Press Q to Quit scanning, or any other key to advance to next line..."
  46.      tx "c1    (   >=Tab     [=Escape     /=Control-Y     {=Control-Q   )n1"
  47.      tx "cbLine c9| cb"left(ltname,33," ")" c9| cb"left(rtname,33," ")"n1c9-----+"left("-",35,"-")"+"left("-",34,"-")"c3"
  48.      li=0
  49.      i=0
  50.      do x=1 to 99999 while ~eof(lt)
  51.           i=i+1
  52.           l=translate(readln(lt),">[/{",d2c(9)"")
  53.           r=translate(readln(rt),">[/{",d2c(9)"")
  54.           if compare(l,r)~=0 then do
  55.                if li=20 then li=0
  56.                     else li=li+1
  57.                line=left(i,4," ")"c9 | c3"left(l,33," ")"c9 | c3"left(r,33," ")
  58.                tx line
  59.                if z="Y" | li=20 then do
  60.                     getchar
  61.                     k=result
  62.                     if k=oops then exit
  63.                     if k="Q" then leave x
  64.                     end
  65.                end
  66.           end
  67.  
  68. QUIT:
  69.      call close(lt)
  70.      call close(rt)
  71.      signal LOOP
  72.  
  73.